<%@ include file="/WEB-INF/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><decorator:title default="OpenSource Side" /></title>
<decorator:head />
<link rel="stylesheet" href="<c:url value="/css/default.css" />" />
<link rel="stylesheet"
	href="<c:url value="/css/redmond/jquery-ui-1.8.4.custom.css" />" />
<script type="text/javascript"
	src="<c:url value="/js/jquery-1.4.2.min.js" />"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-ui-1.8.4.custom.min.js" />"></script>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4468734-7");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript">
$(function() {
	var type = $("#type"), name = $("#name"), url = $("#url"), categoryName = $("#categoryName"), category = $("#category");
	$('#shareDialog').dialog({
		autoOpen: false,
		width: 520,
		buttons: {
			'Save': function() {
				var obj = '{"name":"' + name.val() + '","url":"' + url.val() + '"';
				if(category.val()!=''){					
					obj += ',"' + categoryName.val() + '":"' + category.val() + '"';
				}
				obj += '}';
				$.ajax({
					url: '/ajax/admin/share.do?type=' + type.val() + '&obj=' + obj,
					type: 'POST',
					timeout: 10000,
					error: function(){
						$("#message").addClass("ui-state-error");
						$("#message").html("<span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong></strong>Add failed!");
						setTimeout(function(){$("#message").html("").removeClass("ui-state-error");},5000);
					},
					success: function(data){
						if(data.search('Errors occur') != -1){
							$("#message").addClass("ui-state-error");
							$("#message").html("<span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong></strong>Add failed!" + data);
							setTimeout(function(){$("#message").html("").removeClass("ui-state-error");},5000);
						}else{
							$("#message").addClass("ui-state-highlight");
							$("#message").html("<span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong></strong>Add successfully!");
							setTimeout(function(){$("#message").html("").removeClass("ui-state-highlight");},5000);
						}
					}
				});
				$(this).dialog('close');
			},
			Cancel: function() {$(this).dialog('close');}
		},
		close: function() {
			name.val('');type.val('');url.val('http://'); categoryName.val('');category.val('');
		}
	});
});

function share(type){
	$("#type").val(type);
	$('#shareDialog').dialog({
		title:'Share a ' + type,
	});
	$('#shareDialog').dialog('open');
}
function shareWithCategory(type,categoryName,category){
	$("#categoryName").val(categoryName);
	$("#category").val(category);
	share(type);
}
</script>
</head>
<body>
<div id="top"><%@ include file="/WEB-INF/common/top.jsp"%></div>
<!-- <div id="header"><img src="/images/opensourceside-logo.png" /></div> -->
<div id="horizMenu"><%@ include file="/WEB-INF/common/menu.jsp"%></div>
<div id="main">
<table class="mainTable">
	<tr>
		<td class="navTd">
		<div class="nav"><%@ include file="/WEB-INF/common/tagTree.jsp"%></div>
		</td>
		<td class="mainTd">
		<div class="main">
		<div id="message" class="ui-widget"></div>
		<decorator:body /></div>
		</td>
	</tr>
</table>
</div>
<div id="footer"><%@ include file="/WEB-INF/common/footer.jsp"%></div>
<div id="shareDialog">
<form><input type="hidden" name="type" id="type"><input
	type="hidden" name="categoryName" id="categoryName"><input
	type="hidden" name="category" id="category">Name/Title(*):<br />
<input type="text" name="name" id="name" style="width: 300px;"><br />
Url(*):<font style="color: green; font-size: 11px;">must starts
with http:// or https://</font><br />
<input type="text" name="url" id="url" style="width: 300px;"
	value="http://"></form>
</div>
</body>
</html>
